/**
 * JavaScript Document
 * @author sijian zhang
 */
/**
 * 
 * @param {Object} id
 * @param {Object} dis
 * @param {Object} evtType
 * 
 */



function TabClass(id ,dis , evtType , selectOn){
	tabs = function(id ,dis , evtType){
	this.name = String(id);
	this.disp = dis || 1;
	this.size = 1
	this.selectOn = selectOn || "selectOn"
	this.evt = evtType || "click";
	this.root = document.getElementById(id);
	$sj.util.addEvent(this.evt , this.changeDisp , this.root)
	this.headlId = id + "Tab" + this.disp ; //一开始显示的头部
	this.headl = document.getElementById(id + "Tab" + this.disp)
	this.bodyId = id + "Tab" + this.disp + "Con" ; //显示的主体
	if(window.tabMap){
		tabMap.put(id , this.headlId)
	}
	else{
		tabMap = $sj.Map("tabMap")
		tabMap.put(id , this.headlId)
	}
	while(this.headl != undefined){
				if(this.size != this.disp){
					
					$sj.util.hidden(document.getElementById(id + "Tab" + this.size + "Con"))
				}
				else{
					
					$sj.util.addClass(this.selectOn , document.getElementById(id + "Tab" + this.size))
				}
				this.size += 1
				this.headlId = id + "Tab" + this.size;
				this.headl = document.getElementById(this.headlId);
			}
			this.size -= 1
			
	}
	
	tabs.prototype = {
		add : function(){
			deBug(this.size)
			deBug(this.name)
		},
		del : function(w){
			//deBug(this.size)
			deBug(valueOf(w))
		},
		classOn : function(){
			return this.selectOn
		},
		changeDisp : function(){
			ev = window.event || arguments[0];
			srcE = ev.target || ev.srcElement;
			rootId = this.id || srcE.id.replace(new RegExp(/(Tab)\d+$/g) , "")
			var dispId = tabMap.get(rootId)
			
			if(srcE.id.indexOf("Con") < 0 && srcE.id.indexOf("Tab") != -1){
				$sj.util.removeClass("selectOn" , $obj(dispId))
				$sj.util.hidden($obj(dispId + "Con"))
				$sj.util.addClass("selectOn" , $obj(srcE.id))
				$sj.util.show($obj(srcE.id + "Con"))
				tabMap.put(rootId , srcE.id)
			}
			
		}
	}
	return new tabs(id ,dis , evtType)
}




